const mongoose = require( 'mongoose' );

mongoose.connect( 'mongodb://localhost:27017/bk-2001', { useNewUrlParser: true, useUnifiedTopology: true } );

const schema = new mongoose.Schema( {
    name: {
        type: String,
        require: true,
        minlength: 2
    },
    age: {
        type: Number,
        default: 15,
        min:13
    },
    sex: String,
    phone: String,
    email: String,
    hobies:[String]
} );



const model = mongoose.model( 'Student', schema, 'user' ); 

 model.insertMany( {
     name: 'aa',
     age: 21,
     sex: '先生',
     phone: '124324324234',
     email: 'aaa@aa.com',
     hobies: [ '看书', '写作业' ]
 } ).then( ret => console.log( ret ) )
